package systemFunc

import (
	"fmt"
	"time"
)

func DateFunc() {
	// 获取当前时间
	date := time.Now()
	fmt.Printf("time是%T类型\n", date)
	fmt.Printf("年 = %v\n", date.Year())
	fmt.Printf("月 = %v\n", date.Month())
	fmt.Printf("月 = %v\n", int(date.Month()))
	fmt.Printf("日 = %v\n", date.Day())
	fmt.Printf("时 = %v\n", date.Hour())
	fmt.Printf("分 = %v\n", date.Minute())
	fmt.Printf("秒 = %v\n", date.Second())
	// 输出格式化日期
	fmt.Printf("%02d-%02d-%02d %02d:%02d:%02d\n", date.Year(),
		date.Month(), date.Day(), date.Hour(), date.Minute(), date.Second())

	// 函数格式化日期
	s := date.Format("2006/01/02 15:04:05")
	fmt.Printf("s: %v\n", s)

	// 时间常量,不够1000的,只能从低阶乘,不能从高阶除
	i := 0
	for {
		i++
		fmt.Printf("i=%v\t", i)
		if i == 10 {
			break
		}
		time.Sleep(time.Millisecond * 100)
	}
	fmt.Println()

	// 获取时间戳
	i2 := time.Now().Unix()
	fmt.Printf("i2: %v\n", i2)
}
